<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/21
 * Time: 19:16
 */
class 跨域加载
{

}

?>
php 端: demo.php
<?php
    $result =array('content'=>$_GET['content']);
    function jsonp($result){
        return $_GET['callback'] . '(' . urldecode(json_encode($result)) . ')';
    }
    echo jsonp($result);
?>


客户端：demo.js
<script>
    $.ajax({
        url      : 'http://127.0.0.1/demo.php',
        data     :{'content':'this is a test'},
        dataType : 'jsonp',
        jsonp    : 'callback',
        success  : function(res) {
            console.log(res);
        }
    });
</script>